// 1.通过子传父 A -> App
// 2.通过父传子 App -> B
import { useState } from 'react'

function A ({onGetSonAName}) {
  // Son组件中的数据
  const name = 'this is A name'
  return (
    <div>
      this is A component,
      <button onClick={() => onGetSonAName(name)}>send</button>
    </div>
  )
}
function B ({ name }) {
  return (
    <div>
      this is B component
      {name}
    </div>
  )
}
function App() {
  const [name, setName] = useState('')
  const getAname = (name) => {
    console.log(name)
    setName(name)
  }
  return (
    <div>
     this is App
     <A onGetSonAName={getAname}/>
     <B name={name}/>
    </div>
  );
}

export default App;
